<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;

class SettingController extends Controller
{

    public function edit_password() {
        $edit = false;
        $user = \Auth::user();
        return view('admin.password', compact("user", "edit"));
    }

    public function store_password(Request $request) {
        $user = \Auth::user();
        $this->validate($request, [
            'password'=>'required|min:6|confirmed',
            'password_confirmation' => 'required|min:6'
        ]);

        $user->update(["password" => bcrypt($request->input("password"))]);

        $edit = true;
        return view('admin.password', compact("user", "edit"));
    }
}
